aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/[username]/+page.svelte
blob: 4dc4ee63b2b3d96ac6871ad8389b680724f1663e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<script>
	import { browser } from '$app/environment';
	import { onMount } from 'svelte';
	import { Icon, PageNotFound } from '$comp';
	import { copy } from '$lib/utils';
	import { t } from '$lib/translations';
	export let data;

	let { subject } = data;

	let lightningAddress = `${data?.username}@coinos.io`;

	onMount(async () => {
		if (browser) {
			let { default: QRCodeStyling } = await import('qr-code-styling');
			const qrCode = new QRCodeStyling({
				width: window.screen.width < 640 ? 250 : 300,
				type: 'canvas',
				data: lightningAddress,
				image: '/images/invoice.svg',
				backgroundOptions: {
					color: 'rgba(0, 0, 0, 0)'
				},
				dotsOptions: {
					type: 'rounded'
				},
				imageOptions: {
					hideBackgroundDots: false
				}
			});

			qrCode.append(document.getElementById('qr'));
		}
	});

	let followed = false;
</script>

<div class="container px-4 flex flex-wrap">
	<div class="p-10 pt-20">
		<h1 class="text-3xl font-bold">{subject.username}</h1>

		<p class="text-secondary w-64">
			{subject.address && subject.address !== 'null' ? subject.address : ''}
		</p>

		<!-- TODO
      we need to hook this up
      <button
      class="border rounded-full py-2 w-28 font-semibold flex justify-center items-center text-sm"
      on:click={() => (followed = !followed)}
      ><Icon icon={followed ? 'minus' : 'plus'} style="mr-1" />
      {$t('user.' + (followed ? 'remove' : 'follow'))}
      </button>
    -->
	</div>

	<div class="space-y-5 md:mt-20 mx-auto w-[350px]">
		<!-- <div class="flex justify-center gap-2"> -->
		<!-- 	<a href={`/${subject.username}`}> -->
		<!-- 		<button -->
		<!-- 			class="rounded-full border py-2 px-5 font-bold hover:opacity-80 w-full mb-2 bg-black text-white" -->
		<!-- 			>Lightning</button -->
		<!-- 		> -->
		<!-- 	</a> -->
		<!-- 	<a href={`/${subject.username}/bitcoin`}> -->
		<!-- 		<button class="rounded-full border py-2 px-5 font-bold hover:opacity-80 w-full mb-2" -->
		<!-- 			>Bitcoin</button -->
		<!-- 		> -->
		<!-- 	</a> -->
		<!-- </div> -->
		<div
			on:click={() => copy(lightningAddress)}
			id="qr"
			class="cursor-pointer w-[292px] md:w-[342px] h-[342px] border border-lightgrey rounded-3xl flex p-5 justify-center items-center relative mx-auto"
		/>


		<div
			class="bg-primary font-semibold rounded-xl text-sm p-3 flex justify-between items-center"
		>
			<span class="mx-auto">{lightningAddress}</span>
			<button class="hover:opacity-80" on:click={() => copy(lightningAddress)}>
				<Icon icon="copy" style="ml-2" />
			</button>
		</div>
  <p class="text-center">This is a re-usable <a href="https://lightningaddress.com/" class="underline" target="_blank">lightning address</a></p>
	</div>
</div>